package com.xiaoke.java2;

/**
 * 标量替换测试
 * -Xms100m -Xmx100m -XX:+DoEscapeAnalysis -XX:+PrintGC -XX:-EliminateAllocations
 *
 *
 * @author yd
 * @version 1.0
 * @date 2022/2/21 23:39
 */
public class ScalarReplace {

    public static class User{
        public int id;
        public String name;
    }
    public static void alloc(){
        User user = new User();
        user.id = 5;
        user.name = "www.atuguigu.com";
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        for (int i = 0; i < 10000000; i++) {
            alloc();
        }
        //查看执行时间
        long end = System.currentTimeMillis();
        System.out.println("花费的时间为: " + (end - start) + "ms");


    }



}
